using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Content;

namespace TimeWar
{
    public class Tardis: TimeWarSceneItem
    {

        protected Game gameObj = null;

        public Tardis(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
            gameObj = game;
            object3D = new ThreeDimensionalObject();
            object3D.ModelLocation = "Content\\Models\\TARDIS";
            object3D.Scale = 50;
            object3D.Initialize();
        }


        public Tardis(Game game, String modelLocn)
            : base(game)
        {
            // TODO: Construct any child components here
            gameObj = game;
            object3D = new ThreeDimensionalObject();
            object3D.ModelLocation = modelLocn;
            object3D.Scale = 50;
            object3D.Initialize();
        }

        public override void Render()
        {
            object3D.Draw();
            //base.Render();
        }


        public override void Update(TimeSpan time, TimeSpan elapsedTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                gameObj.Exit();
            }

            //modelRotation += (float)elapsedTime.TotalMilliseconds * MathHelper.ToRadians(0.1f);
            //modelRotation = 270;
            if (GamePad.GetState(PlayerIndex.One).DPad.Left == ButtonState.Pressed)
            {
                object3D.RollLeft(1);
                
            }
            else if (GamePad.GetState(PlayerIndex.One).DPad.Right == ButtonState.Pressed)
            {
                object3D.RollRight(1);
            }
            else if (GamePad.GetState(PlayerIndex.One).DPad.Up == ButtonState.Pressed)
            {
                object3D.PitchDown(1);
            }
            else if (GamePad.GetState(PlayerIndex.One).DPad.Down == ButtonState.Pressed)
            {
                object3D.PitchUp(1);
            }

            if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y < 0)
            {
                object3D.MoveForwards(1);
            }
            else if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.Y > 0)
            {
                object3D.MoveBackwards(1);
            }

            if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X < 0)
            {
                object3D.StrafeLeft(1);
            }
            else if (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X > 0)
            {
                object3D.StrafeRight(1);
            }
            


        }


    }
}
